package com.nlgc365.designpattern.Chapter04_Pattern.Creation.P01_Singleton.Usage.IDGenerators;

import java.util.concurrent.atomic.AtomicLong;

/**
 * 通过枚举来做到单例, 防止反射创建多个对象.
 */
public enum IdGenerator7 {
    INSTANCE;
    private AtomicLong atomicLong = new AtomicLong(0);

    public long getId() {
        return atomicLong.getAndIncrement();
    }
}
